package com.study.springboot.SpringBoot_A.service.impl;

import com.study.springboot.SpringBoot_A.bean.User;
import com.study.springboot.SpringBoot_A.dao.UserRepository;
import com.study.springboot.SpringBoot_A.mapper.UserMapper;
import com.study.springboot.SpringBoot_A.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.UUID;

/**
 * @author 赵超
 * @Description
 * @create 2018-03-23 9:36
 **/
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    @Autowired
    private UserMapper userMapper;

    @Cacheable(value = "findByUserName")
    @Override
    public User findByUserName(String userName) {
        return userRepository.findByUserName(userName);
    }

    @Override
    public Long getCountOfUser() {
        return userRepository.getCountOfUser();
    }

    @Override
    public List<User> findAll() {
        return userRepository.findAll();
    }

    @Override
    public List<User> findByNickNameOrUserName(String nickName, String userName) {
        return userRepository.findByNickNameOrUserName(nickName, userName);
    }

    @Override
    public List<User> getAll() {
        return userMapper.getAll();
    }

    @Override
    public Integer addUser(String userName, String nickName, String passWord) {
        return userMapper.addUser(userName, nickName, passWord);
    }
}
